﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace LayoutTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 5; i++)
            {
                Button b = new Button();
                b.Text = "Button " + i.ToString();
                groupBox1.Controls.Add(b);
            }

            for (int i = 0; i < 5; i++)
            {
                Button b = new Button();
                b.Text = "Button " + i.ToString();
                flowLayoutPanel1.Controls.Add(b);
            }

            tableLayoutPanel1.AutoSize = true;
            tableLayoutPanel1.GrowStyle = TableLayoutPanelGrowStyle.AddRows;
            //tableLayoutPanel1.Dock = DockStyle.Top;
            tableLayoutPanel2.AutoSize = true;
            tableLayoutPanel2.GrowStyle = TableLayoutPanelGrowStyle.AddColumns;

            for (int i = 0; i < 5; i++)
            {
                Button b = new Button();
                b.AutoSize = true;
                b.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
                b.Text = "Button ABCDEFGHIJKLMOPQRST" + i.ToString();
                TableLayoutPanelCellPosition pos =
                   new TableLayoutPanelCellPosition(0, i);
                tableLayoutPanel1.SetCellPosition(b, pos);
                tableLayoutPanel1.Controls.Add(b);
            }
            for (int i = 0; i < 5; i++)
            {
                Button b = new Button();
                b.Text = "Button " + i.ToString();
                tableLayoutPanel2.Controls.Add(b);
            }
        }
    }
}
